<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@taglib uri="/WEB-INF/tld/pageutil.tld" prefix="pu"%>
<%@taglib uri="/WEB-INF/tld/pageable.tld" prefix="pageable"%>
<%@taglib uri="http://java.sun.com/jstl/core" prefix="c"%>
<%@taglib uri="http://java.sun.com/jstl/core_rt" prefix="c-rt"%>
<%@taglib uri="http://java.sun.com/jstl/fmt_rt" prefix="fmt-rt"%>
<script>
$(function(){
	if(document.theForm.taskGroupId.value!=''){
		doAR('/ecadmin/cs/taskGroup/page.do?iamlazy=taskGroupUsers&taskGroupId='+document.theForm.taskGroupId.value+'&columnName=createUser&username=${param.createUser}', 'createUser');
	}
	if(document.theForm.myTaskGroupId.value!=''){
		doAR('/ecadmin/cs/taskGroup/page.do?iamlazy=taskGroupUsers&taskGroupId='+document.theForm.myTaskGroupId.value+'&columnName=responser&username=${param.responser}', 'responser');
	}
});
</script>
<script type="text/javascript" charset="UTF-8" src="/ecadmin/js/jquery.datepick.js"></script>
<script type="text/javascript" charset="UTF-8" src="/ecadmin/js/jquery.datepick-zh-CN.js"></script>
<link rel="stylesheet" type="text/css" href="/ecadmin/css/smoothness.datepick.css" />
<style>
<!--
.tb-2{border:1px solid #ccc; width:100%; vertical-align:text-bottom;}
.tb-2 th{background:#ffe9b5; color:#631;text-align:center; font-weight:bold; font-size:13px; padding:.25em;*padding:.35em .2em .15em;vertical-align:middle}
.tb-2 td{padding:6px 5px;*padding:6px 5px 4px;text-align:center;}

.tb-2 td {
text-align:left;
}
.tb-2 tr:hover{background:#fffae5;}
-->
</style>

<c-rt:set var="hqlUser" value="from User where group.code like ?"/>
<c-rt:set var="pvsUser" value="${pu:addToList('parasUser', 'C%')}"/>
<c-rt:set var="users" value="${pu:queryByHql(hqlUser, pvsUser, null)}"/>
${pu:reqSet('menu', pu:get('com.yaodian100.core.menu.entity.Menu', 'WorkOrder.status')) }
<br />
<h1>批次分派
</h1>
<%--
${pu:reqSet('q', pu:get('com.yaodian100.crm.cs.entity.Question', '8a8080c72741d923012741e33fb80002')) }
<c-rt:forEach items="${q.answers }" var="a">
${a.id }<br/>
</c-rt:forEach>
--%>
<form name="theForm" method="post">
<input type="hidden" name="iamlazy" id="iamlazy" value="list"/>
<table>
<%--
<c-rt:if test="${pu:isCRMManager(pu:username())}">
<tr>
<td>处理人：<select name="responser" id="responser">
	<option value="">请选择</option>
	<c-rt:forEach items="${users }" var="user">
	<option value="${user.username }" ${user.username==param.responser?'selected="selected"':'' }>${user.username }</option>
	</c-rt:forEach>
	</select>
</td>
<td></td>
</tr>
</c-rt:if>
 --%>
<tr>
<td>
订单编号：<input size="13" type="text" name="orderId" value="${param.orderId }"/>
会员编号：<input size="10" type="text" name="memberId" value="${param.memberId }"/>
</td><td>
</td>
</tr>
<tr>
<td>
时间区间(yyyy-MM-dd)：
<input type="text" name="startDate" id="startDate" value="${param.startDate }"/>
~
<input type="text" name="endDate" id="endDate" value="${param.endDate }"/>
工单编号：<input size="10" type="text" name="workOrderId" value="${param.workOrderId }"/>
问题单编号：<input size="16" type="text" name="domainId" value="${domainId}"/>
</td>
<td></td>
</tr>
<tr>
<td>
<table><tr><td>
${pu:reqSet('taskGroups', pu:queryByHql('from TaskGroup order by id asc', null, null)) }
建立人分组：
</td>
<td>
<select name="taskGroupId" onchange="doAR('/ecadmin/cs/taskGroup/page.do?iamlazy=taskGroupUsers&taskGroupId='+this.value+'&columnName=createUser&username=${param.createUser }', 'createUser')">
<option value="">请选择</option>
<c-rt:forEach items="${taskGroups }" var="taskGroup">
<option value="${taskGroup.id }" <c-rt:if test="${taskGroup.id==param.taskGroupId }">selected="selected"</c-rt:if>>${taskGroup.name }</option>
</c-rt:forEach>
</select>
</td>
<td>
建立人：
</td>
<td>
<div id="createUser" class="float:left"><select name="createUser"></select></div>
</td>
<td>
${pu:listAdd('myTaskGroupParams', pu:user().username) }
${pu:reqSet('myTaskGroups', pu:queryByHql('from TaskGroupUser where user.username=? order by id asc', pu:arrayGet('myTaskGroupParams'), null)) }
处理分组：
</td>
<td>
<select name="myTaskGroupId" onchange="doAR('/ecadmin/cs/taskGroup/page.do?iamlazy=taskGroupUsers&taskGroupId='+this.value+'&columnName=responser&username=${param.responser }', 'responser')">
<option value="">请选择</option>
<c-rt:forEach items="${myTaskGroups}" var="myTaskGroup">
<option value="${myTaskGroup.taskGroup.id }" <c-rt:if test="${myTaskGroup.taskGroup.id==param.myTaskGroupId}">selected="selected"</c-rt:if>>${myTaskGroup.taskGroup.name }</option>
</c-rt:forEach>
</select>
</td>
<td>
处理人：
</td>
<td width="200">
<div id="responser" style="float:left"><select name="responser"></select></div>
</td></tr></table>
</td>
</tr>
<tr>
<td>
<script>
$(function(){
	doAR('/ecadmin/cs/page.do?iamlazy=cqTypeList&class1=${param.class1}', 'class1Zone');
	doAR('/ecadmin/cs/page.do?iamlazy=subTypeList&class2=${param.class2}&parentId=${param.class1}', 'class2Zone');
	doAR('/ecadmin/cs/page.do?iamlazy=level3List&commonQuestionType=${param.commonQuestionType}&parentId=${param.class2}', 'commonQuestionTypeZone');
});
</script>
<table><tr><td>
问题大类：</td><td><div id="class1Zone"></div></td><td>
问题中类：</td><td><div id="class2Zone"></div></td><td>
问题小类：</td><td><div id="commonQuestionTypeZone"></div>
</td></tr></table>
</td>
</tr>
<tr>
<td>
${pu:reqSet('logisticProviders', pu:queryByHql('from LogisticProvider order by id asc', null, null)) }
配送商：<select name="deliver">
<option value="">请选择</option>
<c-rt:forEach items="${logisticProviders }" var="lp">
<option value="${lp.id }" <c-rt:if test="${lp.id==param.deliver }">selected="selected"</c-rt:if>>${lp.name }</option>
</c-rt:forEach>
</select>
商品线：<select name="categoryId">
<option value="">请选择</option>
<c-rt:forEach items="${pu:listCategoryLevel0()}" var="category">
<option value="${category.id }" <c-rt:if test="${category.id==param.categoryId}">selected="selected"</c-rt:if>>${category.name }</option>
</c-rt:forEach>
</select>
</td>
</tr>
<tr>
<td>
处理等级：<select name="priority">
<option value="">请选择</option>
<option value="0" <c-rt:if test="${param.priority == '0'}">selected="selected"</c-rt:if>>函件</option>
<option value="1" <c-rt:if test="${param.priority == '1'}">selected="selected"</c-rt:if>>一般件</option>
<option value="2" <c-rt:if test="${param.priority == '2'}">selected="selected"</c-rt:if>>急件</option>
<option value="3" <c-rt:if test="${param.priority == '3'}">selected="selected"</c-rt:if>>特急件</option>
</select>
状态：
<select name="status">
<option value="">请选择</option>
<option value="initNotget" <c-rt:if test="${'initNotget'==param.status }">selected="selected"</c-rt:if>>初始－未取得</option>
<c-rt:forEach items="${menu.options}" var="option">
<option value="${option.value.code }" <c-rt:if test="${option.value.code==param.status }">selected="selected"</c-rt:if>>${option.value.name }</option>
</c-rt:forEach>
</select>
审核状态：
<select name="approveStatus">
<option value="">请选择</option>
<option value="0" <c-rt:if test="${param.approveStatus=='0' }">selected="selected"</c-rt:if>>待审核</option>
<option value="1" <c-rt:if test="${param.approveStatus=='1' }">selected="selected"</c-rt:if>>已核可</option>
<option value="2" <c-rt:if test="${param.approveStatus=='2' }">selected="selected"</c-rt:if>>已注销</option>

</select>
问题类型：
<select name="questionType">
<option value="">请选择</option>
<option value="CommonQuestion" <c-rt:if test="${param.questionType=='CommonQuestion' }">selected="selected"</c-rt:if>>客服问答</option>
<option value="CommonQuestion_product" <c-rt:if test="${param.questionType=='CommonQuestion_product' }">selected="selected"</c-rt:if>>商品问答</option>
<option value="PayByProductArrive" <c-rt:if test="${param.questionType=='PayByProductArrive' }">selected="selected"</c-rt:if>>货到付款审核</option>
<option value="ReturnProductApply" <c-rt:if test="${param.questionType=='ReturnProductApply' }">selected="selected"</c-rt:if>>退货申请</option>
<option value="ChangeProductException" <c-rt:if test="${param.questionType=='ChangeProductException' }">selected="selected"</c-rt:if>>换货单（异常）</option>
<option value="ReturnProductException" <c-rt:if test="${param.questionType=='ReturnProductException' }">selected="selected"</c-rt:if>>退货单（异常）</option>

</select>
</td>
<td></td>
</tr>
<tr>
<td><input type="button" id="searchWorkOrder" value="搜索"/></td>
<td></td>
</tr>
</table>
<table>
<tr>
<td><input type="button" value="我要派件" id="toAssign"/><input type="button" value="汇出CSV" id="csv"/></td>
</tr>
</table>
</form>
<form name="woIdForm" method="post">
<table class="tb-2" width="100%">
			<tr>
				<th><input type="checkbox" id="checkAll" />全选</th>
				<th style="width:40px">ID</th>
				
				<th style="width:120px">
				<table width="100%">
				<tr>
				<th style="border-bottom:1px solid #F80;">问题单编号</th>
				</tr>
				<tr>
				<th>订单编号</th>
				</tr>
				</table>
				
				
				</th>
				
				
				
				<th style="width:70px">
				<table width="100%">
				<tr>
				<th style="border-bottom:1px solid #F80;">处理等级</th>
				</tr>
				<tr>
				<th>类型</th>
				</tr>
				</table>
				</th>
				<th style="width:40px">状态</th>
				
				<th style="width:100px">
				<table width="100%">
				<tr>
				<th style="border-bottom:1px solid #F80;">处理人</th>
				</tr>
				<tr>
				<th>处理群组</th>
				</tr>
				</table>
				</th>
				
				<th style="width:50px">
				<table width="100%">
				<tr>
				<th style="border-bottom:1px solid #F80;">审核群组</th>
				</tr>
				<tr>
				<th>审核状态</th>
				</tr>
				</table>
				</th>
				
				<th style="width:100px">
				<table width="100%">
				<tr>
				<th style="border-bottom:1px solid #F80;">建立人</th>
				</tr>
				<tr>
				<th>建立人群組</th>
				</tr>
				</table>
				</th>
				
				<th style="width:90px">
				<table width="100%">
				<tr>
				<th style="border-bottom:1px solid #F80;">建立日期</th>
				</tr>
				<tr>
				<th>转单回覆日期</th>
				</tr>
				</table>
				</th>
				
				<th style="width:300px">
				<table width="100%">
				<tr>
				<th style="border-bottom:1px solid #F80;">问题说明</th>
				</tr>
				<tr>
				<th>前单说明</th>
				</tr>
				</table>
				</th>
				
			</tr>


			
			<c-rt:forEach items="${workOrders}" var="result" varStatus="rows_index">
			<c-rt:set var="theStyle" scope="request">
			style="background-color:#ffffff"
			</c-rt:set>
			<c-rt:if test="${pu:subDateInHour(pu:currentDate(), result.createDate)>24}">
			<c-rt:set var="theStyle" scope="request">
			style="background-color:#aaffff"
			</c-rt:set>
			</c-rt:if>
			<c-rt:if test="${pu:subDateInHour(pu:currentDate(), result.createDate)>48}">
			<c-rt:set var="theStyle" scope="request">
			style="background-color:#ffffaa"
			</c-rt:set>
			</c-rt:if>
			<c-rt:if test="${pu:subDateInHour(pu:currentDate(), result.createDate)>72}">
			<c-rt:set var="theStyle" scope="request">
			style="background-color:#ffaaff"
			</c-rt:set>
			</c-rt:if>
			<c-rt:if test="${result.status==2}">
			<c-rt:set var="theStyle" scope="request">
			style="background-color:#ffffff"
			</c-rt:set>
			</c-rt:if>
			<tr class="${rows_index.count % 2 == 0 ? 'bg-yl' : ''}" ${theStyle }>
					<th>
					<c-rt:if test="${result.status!=2}">
					<input type="checkbox" class="assignId" value="${result.id }" name="workOrderIds"/>
					</c-rt:if>
					</th>
					<th>	
					${result.id }<br/>
					
					<a href="<c-rt:url value="/cs/page.do?iamlazy=viewQuestion&id=${result.id}"/>" target="_blank">明细</a><br/>
					
					<c-rt:if test="${user.group.code=='A-30-400-000' || pu:substring(user.group.code, 0, 1)=='C' && !empty result.owner && ( result.question.status==1 || result.question.status==2) }">
					<c-rt:if test="${result.question.status==2}">
					<a target="_blank" href="/ecadmin/cs/page.do?iamlazy=question&forward=newOrder&questionType=${result.question.type.name }&formType=workOrder&questionID=${result.question.id }&workOrderId=${result.id}">成立工单</a>
					</c-rt:if>
					<c-rt:if test="${result.question.status==0 }">
					<a target="_blank" href="/ecadmin/cs/newOrder.do?questionId=${result.question.id }&workOrderId=${result.id}&forward=newOrder&questionType=${result.question.type.name }&formType=workOrder&">成立工单</a>
					</c-rt:if>
					</c-rt:if>
					</th>
					<td width="120">
					<table width="100%">
					<tr>
					<td style="border-bottom:1px solid #ddd;">${result.question.id }</td>
					</tr>
					<tr>
					<td style="word-wrap: break-word;word-break: break-all;">${result.question.extraValue['orderId'].value }</td>
					</tr>
					</table>
					</td>
					
					
					
					
					<td width="50">
					<table width="100%">
					<tr><td style="border-bottom:1px solid #ddd;"><c-rt:if test="${result.priority==0}">
					函件
					</c-rt:if>
					<c-rt:if test="${result.priority==1}">
					一般件
					</c-rt:if>
					<c-rt:if test="${result.priority==2}">
					急件
					</c-rt:if>
					<c-rt:if test="${result.priority==3}">
					特急件
					</c-rt:if></td></tr>
					<tr><td>
					<c-rt:if test="${result.question.type.name=='CommonQuestion' }">
						<c-rt:if test="${result.question.extraValue['isProductQAA'].value=='true' }">
							商品问答
						</c-rt:if>
						<c-rt:if test="${result.question.extraValue['isProductQAA'].value!='true' }">
							客服问答
						</c-rt:if>
					</c-rt:if>
					<c-rt:if test="${result.question.type.name!='CommonQuestion' }">
					${result.question.type.description }
					</c-rt:if>
					
					</td></tr>
					</table>
					
					</td>
					
					<td width="40">
					${pu:menuOption('WorkOrder.status', pu:toString(result.status)).name }
					</td>
					
					<td width="100">
					<table width="100%"><tr><td style="border-bottom:1px solid #ddd;">
						${result.owner.username}
						
					</td></tr>
					<tr><td>
					<c-rt:if test="${!empty result.responseGroup}">
					${pu:get('com.yaodian100.core.admin.entity.Group', result.responseGroup).description }(${result.responseGroup })
					</c-rt:if>
					</td></tr>
					</table>
					
					</td>
					
					<td width="50">
					<table width="100%"><tr><td style="border-bottom:1px solid #ddd;">
					<c-rt:if test="${!empty result.approveGroup}">
					${pu:get('com.yaodian100.core.admin.entity.Group', result.approveGroup).description }(${result.approveGroup })
					</c-rt:if></td></tr><tr>
					<td>
					<c-rt:if test="${result.approveStatus==0 }">
					待审核
					</c-rt:if>
					<c-rt:if test="${result.approveStatus==1 }">
					已核可
					</c-rt:if>
					<c-rt:if test="${result.approveStatus==2 }">
					已注销
					</c-rt:if>
					</td></tr></table>
					
					</td>
					
					<td width="100">
					<table width="100%"><tr><td style="border-bottom:1px solid #ddd;">${result.createUser }</td></tr>
					<tr><td>
					${pu:reqSet('createUser', pu:get('com.yaodian100.core.admin.entity.User', result.createUser)) }
					<c-rt:if test="${!empty createUser}">
					${createUser.group.description }(${createUser.group.code })
					</c-rt:if>
					</td></tr>
					</table>
					</td>
					
					<td width="80">
					<table width="100%"><tr><td style="border-bottom:1px solid #ddd;"><fmt-rt:formatDate value="${result.createDate }" pattern="yyyy/MM/dd HH:mm"/></td></tr>
					<tr><td>${pu:reqSet('replyHql', 'from WorkOrder where parent.id=?') }
					${pu:reqSet('replyList', null) }
					${pu:listAdd('replyList', result.id) }
					${pu:reqSet('replyWorkOrder', pu:queryByHql(replyHql, pu:arrayGet('replyList'), null)) }
					
					<c-rt:if test="${!empty replyWorkOrder}">
					<c-rt:if test="${!empty replyWorkOrder[0].finishTime}">
					<fmt-rt:formatDate value="${replyWorkOrder[0].finishTime}" pattern="yyyy-MM-dd HH:mm"/>
					</c-rt:if>
					<c-rt:if test="${empty replyWorkOrder[0].finishTime}">
					<b>尚未回覆</b>
					</c-rt:if>
					</c-rt:if>
					<c-rt:if test="${empty replyWorkOrder}">
					未转单
					</c-rt:if></td></tr>
					</table>
					
					</td>
					
					<td >
					<table width="100%">
					<tr><td style="border-bottom:1px solid #ddd;word-wrap: break-word;word-break: break-all;">${result.question.description }</td></tr>
					<tr><td style="word-wrap: break-word;word-break: break-all;">
					${result.comment }
					</td></tr>
					</table>
					
					</td>
				</tr>

			</c-rt:forEach>

	</table>
	
	</form>
<c-rt:set var="url">
<%=application.getContextPath() %>/workOrder/toBatchAssign.do
</c-rt:set>
<pageable:Pageable url="${url}" formname="woForm" key="tp"></pageable:Pageable>
<table width="100%">
<tr>
<td align="right">
${pu:reqSet('currentPage', param.tp_pageable_currentPage) }
<c-rt:if test="${empty param.tp_pageable_currentPage}">
${pu:reqSet('currentPage', 1) }
</c-rt:if>
目前在第${currentPage }页, 资料共${tp.totalRecords }笔</td>
</tr>
</table>
<div id="dialog" style="display:none">
<form name="assignForm" method="post" action="/ecadmin/workOrder/batchAssign.do">
<span id="workOrderIdZone">

</span>
<table>
<tr>
<td>
工单数:<span id="woCount"></span><br/>
派单方式：<select name="assignType" id="assignType"><option value="taskGroup1">单选指派</option><option value="taskGroup2">多选平均指派</option><option value="taskGroup3">多选指定数量分派</option></select>
</td>
</tr>
</table>
<table id="tg1">
<tr>
<td>
${pu:reqSet('myTaskGroupParams', null) }
${pu:listAdd('myTaskGroupParams', pu:user().username) }
${pu:reqSet('myTaskGroups', pu:queryByHql('from TaskGroupUser where user.username=? order by id asc', pu:arrayGet('myTaskGroupParams'), null)) }
负责分组：<select name="taskGroup1"  onchange="doAR('/ecadmin/cs/taskGroup/page.do?iamlazy=taskGroupUsers&taskGroupId='+this.value+'&columnName=responser1', 'responserAssign')"><option value="">请选择</option><c-rt:forEach items="${myTaskGroups}" var="tg"><option value="${tg.taskGroup.id }">${tg.taskGroup.name }</option></c-rt:forEach></select>处理人员：<span id="responserAssign"><select name="responser1"></select></span>
</td>
</tr>
</table>
<table id="tg2" style="display:none">
<tr>
<td>
负责分组：<select name="taskGroup2"  onchange="doAR('/ecadmin/cs/taskGroup/page.do?iamlazy=taskGroupUsers&taskGroupId='+this.value+'&columnName=responser2&showType=multi', 'multi')"><option value="">请选择</option><c-rt:forEach items="${myTaskGroups}" var="tg"><option value="${tg.taskGroup.id }">${tg.taskGroup.name }</option></c-rt:forEach></select><br/>
<span id="multi">
</span>
</td>
</tr>
</table>
<table id="tg3" style="display:none">
<tr>
<td>
负责分组：<select name="taskGroup3"  onchange="doAR('/ecadmin/cs/taskGroup/page.do?iamlazy=taskGroupUsers&taskGroupId='+this.value+'&columnName=responser3&showType=multiAssign', 'multiAssign')"><option value="">请选择</option><c-rt:forEach items="${myTaskGroups}" var="tg"><option value="${tg.taskGroup.id }">${tg.taskGroup.name }</option></c-rt:forEach></select><br/>
<span id="multiAssign">

</span>
</td>
</tr>
</table>
<table>
<tr><td><input type="button" id="assignSubmit" value="确认送出"/><input type="reset" value="取消" id="resetForm"/></td></tr>
</table>
</form>
</div>

<script>
$(document).ready(function(){
	$('#resetForm').click(function(){
		$('#tg1').show();
		$('#tg2').hide();
		$('#tg3').hide();	
	});
	$('#searchWorkOrder').click(function(){
		if(document.theForm.startDate.value!='' && !isValidDate(document.theForm.startDate.value)){
			alert('开始时间格式错误！');
			return;
		}else if(document.theForm.endDate.value!='' && !isValidDate(document.theForm.endDate.value)){
			alert('结束时间格式错误！');
			return;
		}
		$('iamlazy').attr('value', 'list');
		document.theForm.action='<%=application.getContextPath() %>/workOrder/toBatchAssign.do';
		document.theForm.submit();
		//doAR(, 'main', 'theForm');
		
	});
	$('#checkAll').click(function(){
		if($(this).attr('checked')==true){
			$('.assignId').attr('checked', true);
		}else{
			$('.assignId').attr('checked', false);
		}
	
});
	$('#assignSubmit').click(function(){
		isSelected=false;
		$('.assignId').each(function(){
			if($(this).attr('checked')==true){
				isSelected=true;
				$('#workOrderIdZone').append('<input type="hidden" name="workOrderIds" value="'+$(this).attr('value')+'"/>');
			}
		});
		isAssign=false;
		if(document.assignForm.assignType.value=='taskGroup1'){
			if(document.assignForm.responser1.value!=''){
				isAssign=true;
			}
		}else if(document.assignForm.assignType.value=='taskGroup2'){
			$('.multiUsers').each(function(){
				if($(this).attr('checked')==true){
					isAssign=true;
				}
			});
		}else{
			$('.multiAssignUsers').each(function(){
				if($(this).attr('checked')==true){
					isAssign=true;
				}
			});
		}
		if(!isAssign){
			alert('请选择分派的人员');
		}else if(!isSelected){
			alert('请选择工单');
		}else{
			document.assignForm.submit();
		}
	});
	$('#toAssign').click(function(){
		selectedCount=0;
		$('.assignId').each(function(){
			if($(this).attr('checked')==true){
				selectedCount++;
			}
		});
		$('#woCount').html(selectedCount);
		$('#workOrderIdZone').html('');
		if(selectedCount==0){
		alert('请选择工单');
		}else{
		openDialogAssign('派件', 600, 300);
		}
	});
	$('#assignType').change(function(){
		if($(this).attr('value')=='taskGroup1'){
			$('#tg1').show();
			$('#tg2').hide();
			$('#tg3').hide();			
		}else if($(this).attr('value')=='taskGroup2'){
			$('#tg1').hide();
			$('#tg2').show();
			$('#tg3').hide();
		}else{
			$('#tg1').hide();
			$('#tg2').hide();
			$('#tg3').show();
		}
	});
	$('#csv').click(function(){
		isSelected=false;
		$('.assignId').each(function(){
			if($(this).attr('checked')==true){
				isSelected=true;
			}
		});
		if(!isSelected){
			alert('请选择工单');
		}else{
			document.woIdForm.action="/ecadmin/workOrder/downloadCsv.do";
			document.woIdForm.submit();
		}
	});
	$('#startDate').datepick({dateFormat:'yy-mm-dd'});
	$('#endDate').datepick({dateFormat:'yy-mm-dd'});
	
});
var selectedCount=0;
var isSelected=false;
function isValidDate(str){

	var expr = /^([1-2]{1,1}[0-9]{3,3})-([0-1]{1,1}[0-9]{1,1})-([0-3]{1,1}[0-9]{1,1})$/;
	if(!expr.test(str)){
	   return false;
	}
	var strs=str.split("-");
	if(strs.length!=3){
	   return false;
	}

	var date= new Date(parseFloat(strs[0]),parseFloat(strs[1])-1,parseFloat(strs[2]));
	if(date.getFullYear()==parseFloat(strs[0])&&(date.getMonth()+1==parseFloat(strs[1]))&&date.getDate()==parseFloat(strs[2])){
	   return date;
	}
	return false;
	}
function openDialogAssign(title,width,height){
	if ( width =="" || width == 0) width = 500;
	if ( height =="" || height == 0) height = 400;
	if($('div.ui-dialog').size()<=0){
		$('#dialog').dialog(
			{ 
				title:title,
				width:width,
				height:height,
				modal: true
			}
			);
	}else{
		$('div.ui-widget-overlay').css({display:'block'});
		$('div.ui-dialog').css({display:'block'});
	}
	
}

</script>